package com.xiaoze.question.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xiaoze.common.annotation.Log;
import com.xiaoze.common.core.controller.BaseController;
import com.xiaoze.common.core.domain.AjaxResult;
import com.xiaoze.common.enums.BusinessType;
import com.xiaoze.question.domain.QuestionScenarioTactics;
import com.xiaoze.question.service.IQuestionScenarioTacticsService;
import com.xiaoze.common.utils.poi.ExcelUtil;
import com.xiaoze.common.core.page.TableDataInfo;

/**
 * 业务场景策略管理Controller
 *
 * @author 胡昊泽
 * @date 2024-08-02
 */
@RestController
@RequestMapping("/question/tactics" )
public class QuestionScenarioTacticsController extends BaseController {
    @Autowired
    private IQuestionScenarioTacticsService questionScenarioTacticsService;

    /**
     * 查询业务场景策略管理列表
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(QuestionScenarioTactics questionScenarioTactics) {
        startPage();
        List<QuestionScenarioTactics> list = questionScenarioTacticsService.selectQuestionScenarioTacticsList(questionScenarioTactics);
        return getDataTable(list);
    }

    /**
     * 导出业务场景策略管理列表
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:export')" )
    @Log(title = "业务场景管理" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(QuestionScenarioTactics questionScenarioTactics) {
        List<QuestionScenarioTactics> list = questionScenarioTacticsService.selectQuestionScenarioTacticsList(questionScenarioTactics);
        ExcelUtil<QuestionScenarioTactics> util = new ExcelUtil<QuestionScenarioTactics>(QuestionScenarioTactics.class);
        return util.exportExcel(list, "tactics" );
    }

    /**
     * 获取业务场景策略管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(questionScenarioTacticsService.selectQuestionScenarioTacticsById(id));
    }

    /**
     * 新增业务场景策略管理
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:add')" )
    @Log(title = "业务场景管理" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuestionScenarioTactics questionScenarioTactics) {
        return toAjax(questionScenarioTacticsService.insertQuestionScenarioTactics(questionScenarioTactics));
    }

    /**
     * 修改业务场景策略管理
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:edit')" )
    @Log(title = "业务场景管理" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuestionScenarioTactics questionScenarioTactics) {
        return toAjax(questionScenarioTacticsService.updateQuestionScenarioTactics(questionScenarioTactics));
    }

    /**
     * 删除业务场景策略管理
     */
    @PreAuthorize("@ss.hasPermi('question:tactics:remove')" )
    @Log(title = "业务场景管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(questionScenarioTacticsService.deleteQuestionScenarioTacticsByIds(ids));
    }
}
